<style type="text/css">
	a.btnDelete{display:none !important;}
</style>
<script type="text/javascript">
//<![CDATA[        
	function frmValid(){
		with(document.frmReg){
			var tel = getInputHashmap($('[name="tel[]"]'));
			var hp = getInputHashmap($('[name="hp[]"]'));
			var corp_tel = getInputHashmap($('[name="corp_tel[]"]'));
			var corp_fax = getInputHashmap($('[name="corp_fax[]"]'));
						
			if(!checkID(user_id.value,4,12)){
				alert('아이디는 영문/숫자 조합 4~12자 이내로 입력해주세요');
				user_id.focus();
				return;
			}

			if(valid_userid.value !='Y'){
				alert('아이디 중복 체크를 해주세요');
				user_id.focus();
				return;
			}

			if(!checkPass(passwd.value, 6, 12)){
				alert('비밀번호를 6~12자 이내로 입력해주세요');
				passwd.focus();
				return;
			}

			if(passwd.value != chkpasswd.value){
				alert('입력하신 비밀번호가 일치 하지 않습니다.');
				return;
			}
				
			if(tel.length > 0){
				if(!telRegEx.test(tel.join("-"))){
					alert("전화번호를 정확히 입력해주세요");
					return;
				}
			}

			if(hp.length > 0){
				if(!hpRegEx.test(tel.join("-"))){
					alert("핸드폰 번호를 정확히 입력해주세요");
					return;
				}
			}	

			if(corp_tel.length > 0){
				if(!hpRegEx.test(corp_tel.join("-"))){
					alert("근무처 전화 번호를 정확히 입력해주세요");
					return;
				}
			}

			if(corp_fax.length > 0){
				if(!hpRegEx.test(corp_fax.join("-"))){
					alert("근무처 팩스 번호를 정확히 입력해주세요");
					return;
				}
			}	
			submit();
		}
	}

	function frmDelete(){
		if(!confirm('삭제 하시겠습니까?'))return;
		with(document.frmReg){
			dbjob.value = 'd';
			submit();
		}	 
	}

		

	//아이디 유효성 체크
	function validUserID(){
		var userid = $("[name=user_id]").val();
		if(userid){
			if(!checkID(userid,4,12)){
				alert('아이디는 숫자/영문 조합으로 4~12자까지 입력가능합니다.');
				return;
			}
			
			$.ajax({
				type: "GET",
				url: "/member/ajax_valid_userid",
				data: "user_id="+userid+'&id='+$("[name=id]").val(),
				success: function(data){
					var rtn = eval('('+data+')');
					$("[name=valid_userid]").val(rtn.validYN);
					if(rtn.validYN =='Y'){
						$(".uid_msg").html('<font color="blue">사용 가능한 아이디 입니다.</font>');
					}else{
						$(".uid_msg").html('<font color="red">사용 불가능한 아이디 입니다.</font>');
					}		
				},
				error:function(error){alert('에러1');}
			});
		}

	}
	
	$.datepicker.setDefaults({
		dateFormat: 'yy-mm-dd'
	});

	$(function(){
		//삭제버튼
		if($("[name=dbjob]").val() == 'u'){ 
			$("[name=valid_userid]").val('Y'); //수정시 아이디 검증 패스
			$(".btnDelete").show();
		}
		
		$(".datepicker").datepicker({changeMonth: true,changeYear: true,yearRange: "1950" });
		
		$(".btn_calendar").click(function(){
			var index = $(".btn_calendar").index($(this));
			$('.datepicker').eq(index).datepicker('show');	
		});

		//이메일
		$("[name=domain_support]").change(function(){
			if($(this).val()){
				$("[name=mail_domain]").attr("readonly",true);
				$("[name=mail_domain]").val($(this).val());
			}else{
				$("[name=mail_domain]").attr("readonly",false);
				$("[name=mail_domain]").val('');
				$("[name=mail_domain]").focus();
			}
		});

		//아이디 중복확인
		$("[name=user_id]").blur(function(){validUserID()});	
	});
//]]>
</script>

<!--[s] 우편번호 검색 레이어 -->
<div id="layerBg"></div>
<div id="layerArea" class="layer_add"></div>
<!--[e] 우편번호 검색 레이어 -->

<div class="box_type02">
<h2 class="txt">회원리스트</h2>
<p class="icon"><a href="javascript:void(0);" class="icon_m04">매뉴얼</a></p>
<h3 class="txt">기본정보</h3>
<div><?php echo validation_errors(); ?></div>
<!--[s] 쓰기 -->
<form name="frmReg" method="post" action="/member/memberDbjob">
<?php 
	$hidden = array('dbjob'=>$dbjob,'id'=>$id,'valid_userid'=>'N');
	echo form_hidden($hidden);
?>
	<fieldset class="board_write">
		<legend>기본정보</legend>
		<table cellspacing="0" summary="기본정보" class="lines">
			<caption>기본정보</caption>
			<tr>
				<th scope="row" width="128"><p class="point">관리자</p></th>
				<td width="254">
					<div>
						<select name="admin_yn" class="ip_s">
							<option value="N" <?php if($admin_yn=='N'){?>selected<?php }?>>No</option>
							<option value="Y" <?php if($admin_yn=='Y'){?>selected<?php }?>>Yes</option>
						</select>
					</div>
				</td>
				<th scope="row" width="128"><p class="point">등급</p></th>
				<td>
					<div>
						<select name="membership" class="ip_s">
							<?php 
								for($i=1; $i<=9; $i++): 
									$selected = ($membership == $i) ? 'selected' : '';
							?>
								<option value="<?php echo $i;?>" <?php echo $selected;?>><?php echo $i;?></option>
							<?php endfor;?>
						</select>
						<span class="txt_type02">숫자가 낮을수록 높은 등급 입니다.</span>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">아이디</p></th>
				<td width="254" colspan="3">
					<div>
						<input type="text" id="" name="user_id" class="ip_i" style="width:212px;" value="<?php echo $user_id;?>" />
						<span class="txt_type02 uid_msg"></span>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">비밀번호</p></th>
				<td width="254">
					<div>
						<input type="password" id="" name="passwd" class="ip_i" style="width:212px;" value="" />
					</div>
				</td>
				<th scope="row" width="128"><p class="point">비밀번호 확인</p></th>
				<td>
					<div><input type="password" id="" name="chkpasswd" class="ip_i" style="width:212px;" value="" /></div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">성명</p></th>
				<td>
					<div>
						<input type="text" id="" name="" class="ip_i" style="width:212px;" value="<?php echo $name;?>" />
					</div>
				</td>
				<th scope="row"><p class="point">성별</p></th>
				<td>
					<div>
						<ul class="w30 c_box">
							<li><input type="radio" id="" name="gender" class="ip_c" <?php if ($gender == 'M'):?>checked<?php endif;?>  value="M" /><label for="" class="txt_type01">남</label></li>
							<li><input type="radio" id="" name="gender" class="ip_c" <?php if ($gender == 'F'):?>checked<?php endif;?>  value="F" /><label for="" class="txt_type01">여</label></li>
						</ul>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">생년월일</p></th>
				<td>
					<div>
						<input type="text" id="" name="birth_date" class="ip_i datepicker" style="width:148px;" value="<?php echo $birth_date;?>" />
						<a href="javascript:void(0);" class="btn_calendar">달력보기</a>
					</div>
				</td>
				<th scope="row"><p class="point">구분</p></th>
				<td>
					<div>
						<ul class="w30 c_box">
							<li><input type="radio" id="" name="solar_yn" class="ip_c" <?php if ($solar_yn == 'Y'):?>checked<?php endif;?> value="Y" /><label for="" class="txt_type01">음력</label></li>
							<li><input type="radio" id="" name="solar_yn" class="ip_c" <?php if ($solar_yn == 'N'):?>checked<?php endif;?> value="N" /><label for="" class="txt_type01">양력</label></li>
						</ul>
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
	<!--[e] 쓰기 -->
	
	<h3 class="txt">연락처정보</h3>
	<!--[s] 쓰기 -->
	<fieldset class="board_write">
		<legend>연락처정보</legend>
		<table cellspacing="0" summary="연락처정보" class="lines">
			<caption>연락처정보</caption>
			<tr>
				<th scope="row" width="128"><p class="point">주소</p></th>
				<td colspan="3">
					<div>
						<p>
							<input type="text" id="" name="zipcode1" readonly class="ip_i" style="width:23px;" value="<?php echo $zipcode1; ?>" />
							<span class="txt_type01">-</span>
							<input type="text" id="" name="zipcode2" readonly class="ip_i" style="width:23px;" value="<?php echo $zipcode2; ?>" />
							<a href="javascript:findpost('obj1=frmReg.zipcode1&obj2=frmReg.zipcode2&obj3=frmReg.addr1');"><img src="/theme/<?=$_theme?>/images/common/btn_add.gif" class="vam ml6" alt="우편번호찾기" /></a>
						</p>
						<p class="mt4"><input type="text" id="" name="addr1" readonly class="ip_i" style="width:595px;" value="<?php echo $addr1; ?>" /></p>
						<p class="mt4"><input type="text" id="" name="addr2" class="ip_i" style="width:595px;" value="<?php echo $addr2; ?>" /></p>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">이메일</p></th>
				<td colspan="3">
					<div>
						<input type="text" id="" name="mail_id" class="ip_i" style="width:155px;" value="<?php echo $mail_id;?>" />
						<span class="txt_type01">@</span>
						<input type="text" id="" name="mail_domain" class="ip_i" style="width:155px;" value="<?php echo $mail_domain;?>" />
						<select name="domain_support" class="ip_s ml6" style="width:130px;">
							<option value="">직접입력</option>
							<?php 
								foreach($this->config->item('ch_mail_domain') as $key){
									$selected = ($key == $mail_domain) ? 'selected' :'';
									echo "<option value=\"{$key}\" {$selected}>{$key}</option>\n";
								}
							?>
						</select>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">전화번호</p></th>
				<td width="254">
					<div>
						<input type="text" id="" name="tel[]" maxlenth="3" class="ip_i" style="width:23px;" value="<?php echo $tel1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="tel[]" maxlenth="4" class="ip_i" style="width:43px;" value="<?php echo $tel2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="tel[]" maxlenth="4" class="ip_i" style="width:43px;" value="<?php echo $tel3;?>" />
					</div>
				</td>
				<th scope="row" width="128"><p class="point">휴대폰</p></th>
				<td>
					<div>
						<input type="text" id="" name="hp[]" maxlenth="3" class="ip_i" style="width:23px;" value="<?php echo $hp1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="hp[]" maxlenth="4" class="ip_i" style="width:43px;" value="<?php echo $hp2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="hp[]" maxlenth="4" class="ip_i" style="width:43px;" value="<?php echo $hp3;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">메일수신</p></th>
				<td>
					<div>
						<ul class="w40 c_box">
							<li><input type="radio" id="" name="mailling_yn" value="Y" class="ip_c" <?php if ($mailling_yn == 'Y'):?>checked<?php endif;?> /><label for="" class="txt_type01">수신함</label></li>
							<li><input type="radio" id="" name="mailling_yn" value="N"  class="ip_c" <?php if ($mailling_yn == 'N'):?>checked<?php endif;?> /><label for="" class="txt_type01">수신거부</label></li>
						</ul>
					</div>
				</td>
				<th scope="row"><p class="point">SMS수신</p></th>
				<td>
					<div>
						<ul class="w40 c_box">
							<li><input type="radio" id="" name="sms_yn" value="Y" class="ip_c" <?php if ($sms_yn == 'Y'):?>checked<?php endif;?> /><label for="" class="txt_type01">수신함</label></li>
							<li><input type="radio" id="" name="sms_yn" value="N" class="ip_c" <?php if ($sms_yn == 'N'):?>checked<?php endif;?> /><label for="" class="txt_type01">수신거부</label></li>
						</ul>
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
	<!--[e] 쓰기 -->
	
	<h3 class="txt">근무처정보</h3>
	<!--[s] 쓰기 -->
	<fieldset class="board_write">
		<legend>근무처정보</legend>
		<table cellspacing="0" summary="근무처정보" class="lines">
			<caption>근무처정보</caption>
			<tr>
				<th scope="row"><p class="point">회사명</p></th>
				<td>
					<div>
						<input type="text" id="" name="corp_name" class="ip_i" style="width:212px;" value="<?php echo $corp_name;?>" />
					</div>
				</td>
				<th scope="row"><p class="point">직위</p></th>
				<td>
					<div>
						<input type="text" id="" name="corp_position" class="ip_i" style="width:212px;" value="<?php echo $corp_position;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">주소</p></th>
				<td colspan="3">
					<div>
						<p>
							<input type="text" id="" name="corp_zipcode1" readonly class="ip_i" style="width:23px;" value="<?php echo $corp_zipcode1; ?>" />
							<span class="txt_type01">-</span>
							<input type="text" id="" name="corp_zipcode2" readonly class="ip_i" style="width:23px;" value="<?php echo $corp_zipcode2; ?>" />
							<a href="javascript:findpost('obj1=frmReg.corp_zipcode1&obj2=frmReg.corp_zipcode2&obj3=frmReg.corp_addr1');"><img src="/theme/<?=$_theme?>/images/common/btn_add.gif" class="vam ml6" alt="우편번호찾기" /></a>
						</p>
						<p class="mt4"><input type="text" id="" name="corp_addr1" readonly class="ip_i" style="width:595px;" value="<?php echo $corp_addr1; ?>" /></p>
						<p class="mt4"><input type="text" id="" name="corp_addr2" class="ip_i" style="width:595px;" value="<?php echo $corp_addr2; ?>" /></p>
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">전화번호</p></th>
				<td width="254">
					<div>
						<input type="text" id="" name="corp_tel[]" class="ip_i" style="width:23px;" value="<?php echo $corp_tel1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="corp_tel[]" class="ip_i" style="width:43px;" value="<?php echo $corp_tel2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="corp_tel[]" class="ip_i" style="width:43px;" value="<?php echo $corp_tel3;?>" />
					</div>
				</td>
				<th scope="row" width="128"><p class="point">FAX</p></th>
				<td>
					<div>
						<input type="text" id="" name="corp_fax[]" class="ip_i" style="width:23px;" value="<?php echo $corp_fax1;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="corp_fax[]" class="ip_i" style="width:43px;" value="<?php echo $corp_fax2;?>" />
						<span class="txt_type01">-</span>
						<input type="text" id="" name="corp_fax[]" class="ip_i" style="width:43px;" value="<?php echo $corp_fax3;?>" />
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
	<!--[e] 쓰기 -->
	
	<h3 class="txt">교회정보</h3>
	<!--[s] 쓰기 -->
	<fieldset class="board_write">
		<legend>교회정보</legend>
		<table cellspacing="0" summary="교회정보" class="lines">
			<caption>교회정보</caption>
			<tr>
				<th scope="row" width="128"><p class="point">세례여부</p></th>
				<td width="254">
					<div>
						<ul class="w30 c_box">
							<li><input type="radio" id="" name="baptism_yn" value="Y" class="ip_c" checked="checked" /><label for="" class="txt_type01">예</label></li>
							<li><input type="radio" id="" name="baptism_yn" value="N" class="ip_c" /><label for="" class="txt_type01">아니오</label></li>
						</ul>
					</div>
				</td>
				<th scope="row" width="128"><p class="point">직분</p></th>
				<td>
					<div>
						<input type="text" id="" name="church_duty" class="ip_i" style="width:212px;" value="<?php echo $church_duty;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row"><p class="point">출석교회</p></th>
				<td>
					<div>
						<input type="text" id="" name="church_name" class="ip_i" style="width:212px;" value="<?php echo $church_name;?>" />
					</div>
				</td>
				<th scope="row"><p class="point">인도자</p></th>
				<td>
					<div>
						<input type="text" id="" name="introducer" class="ip_i" style="width:212px;" value="<?php echo $introducer;?>" />
					</div>
				</td>
			</tr>
			<tr>
				<th scope="row" width="128"><p class="point">가입경로</p></th>
				<td colspan="3">
					<div>
						<ul class="w15 c_box">
							
							<?php foreach($this->config->item('ch_join_path') as $key): 
								$checked = ($key == $join_path) ? 'checked' : '';
							?>
								<li><input type="radio" id="" name="join_path" class="ip_c" <?php echo $checked;?> value="<?php echo $key;?>" /><label for="" class="txt_type01"><?php echo $key?></label></li>
							<?php endforeach; ?>
						</ul>
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
	<!--[e] 쓰기 -->
</form>
<!-- [s] 버튼 -->
<ul class="botton_box mt30">
	<li class="center">
		<?php 
			//버튼 이미지 변경
			$btn_image = ($dbjob == 'i') ? 'btn_ok.gif' : 'btn_modify.gif';
		?>
		<a href="javascript:frmValid();"><img src="/theme/<?=$_theme?>/images/common/<?php echo $btn_image;?>" alt="확인" /></a>
		<a href="javascript:frmDelete();"" class="btnDelete"><img src="/theme/<?=$_theme?>/images/common/btn_delete.gif" alt="삭제" /></a>
		<a href="<?php echo $link_list;?>"><img src="/theme/<?=$_theme?>/images/common/btn_list.gif" alt="목록" /></a>
	</li>
</ul>
<!-- [e] 버튼 -->

<!--[s] Tip -->
<dl id="tip" class="mt30">
	<dt>Tip</dt>
	<dd>인터넷익스플로러의 '호환성보기' 기능을 사용중인 접속자에게 자동으로 최신버전 기준으로 사이트를 출력하도록 처리합니다.</dd>
	<dd>코딩방식에 따라 특정 버전의 브라우저에서 사이트가 깨질수 있으니, 충분한 테스트 후 기능을 설정해 주시기 바랍니다.</dd>
</dl>
<!--[e] Tip -->